<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>个人用户管理平台 - 人才招聘系统</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link th:href="@{/styles/m_css.css}" type="text/css" rel="stylesheet" />
    <link th:href="@{/styles/tips.css}" type="text/css" rel="stylesheet" />
    <link
      rel="stylesheet"
      th:href="@{/js/layui/css/layui.css}"
      type="text/css"
    />
    <script th:src="@{/js/layui/layui.js}"></script>
    <script th:src="@{/js/jquery-3.7.1.min.js}"></script>
    <script th:src="@{/js/http.js}"></script>
  </head>

  <body>
    <div class="user_header" th:insert="~{/commons/ucenter_header}"></div>
    <div class="clear"></div>
    <div class="yun_w1200">
      <div class="yun_m_leftsidebar" th:insert="~{/commons/ucenter_menu}"></div>
      <div class="yun_m_rightsidebar">
        <div class="user_new_tit">
          <span class="user_new_tit_n">我的简历</span>
          <a
            href="./resume1"
            class="user_cjbth"
            style="float: right; margin-top: 7px; margin-right: 10px"
            >创建简历</a
          >
          <div
            class="user_czbth_r"
            style="float: right; background-color: #fff; padding-top: 8px"
          >
            <a href="" class="user_czbth_ys user_czbth_line">隐私设置 </a>
            <a
              href=""
              class="user_czbth_pp user_czbth_line"
              resumeid="2"
              type="pipei"
              >职位速配</a
            >
            <a
              href="javascript:void(0)"
              title="直接粘贴已有的个人简历"
              class="user_czbth_zt"
              onclick=""
              >在线粘贴简历</a
            >
          </div>
        </div>
      </div>

      <div class="yun_m_rightbox fltR mt20 re">
        <div class="user_resume_list">
          <div class="yun_m_index_resume_tit">
            <span class="yun_m_index_resume_span">我的简历</span>
          </div>
          <div class="">
            <div class="clear"></div>

            <div class="user_resume_box" id="addDefaultResume">
              <!-- <div class="user_resume_photo">
                <a href="">
                  <img src="" border="0" />
                </a>
              </div>
              <div class="user_resume_info">
                <div class="user_resume_name">
                  老谭<span class="user_resume_job">软件测试</span
                  ><span class="user_resume_mr">默认</span>
                </div>
                <div class="user_resume_p">
                  35岁<span class="user_resume_line">|</span> 6年以上经验<span
                    class="user_resume_line"
                    >|</span
                  >
                  本科学历
                </div>
                <div class="user_resume_p2">已离职，寻求新工作 - 1周以内</div>
              </div>
              <div class="user_resume_c">
                <div class="user_resume_wzd" id="tipid" rid="2">
                  <span class="user_resume_wzd_name">简历完整度：</span>
                  <div class="user_resume_wzd_b">
                    <span class="user_resume_wzd_c" style="width: 75%"></span>
                  </div>
                  <span class="user_resume_wzd_r">75% </span>
                </div>
                <div class="clear"></div>
                <div class="user_resume_p user_resume_pd">
                  更新日期：2025-06-12 09:23:43
                </div>
                <div class="user_resume_p">被浏览：1</div>
              </div>
              <div class="user_resume_cz">
                <div class="user_resume_cz_p">
                  <a
                    href="javascript:void(0)"
                    class="user_resume_cz_a user_resume_cz_icon5"
                  >
                    删除简历</a
                  >
                </div>
                <div class="user_resume_cz_p">
                  <a href="" class="user_resume_cz_a user_resume_cz_icon3"
                    >修改简历</a
                  >
                </div>
                <div class="user_resume_cz_p">
                  <a
                    href=""
                    target="_blank"
                    class="user_resume_cz_a user_resume_cz_icon4"
                    >预览简历</a
                  >
                </div>
                <div class="user_resume_cz_p">
                  <a
                    href="javascript:void(0)"
                    class="user_resume_cz_a user_resume_cz_icon2"
                    >刷新简历</a
                  >
                </div>
              </div> -->
            </div>
            <div class="user_resume_boxtip">
              <div class="user_resume_boxtip_c">
                <div class="user_resume_boxtip_h1">
                  你的简历缺少项目经历，会极大影响求职成功率哦！
                </div>
                <div class="user_resume_boxtip_p">
                  完善项目经历，可以有效提高求职成功率
                </div>
                <a href="" class="user_resume_boxtip_bth">完善项目经历 </a>
              </div>
            </div>

            <!--  备用简历-->
            <div id="addBackUpResumes">
              <!-- <div class="myresume mt20" style="margin-left: 0px">
                <span class="myresume_by">备用</span>
                <div class="myresume_left">
                  <div class="myresume_name">
                    <a href="">Java开发</a>
                  </div>
                  <div class="user_resume_wzd" id="tipid" rid="1044751">
                    <span class="user_resume_wzd_name">简历完整度：</span>
                    <div class="user_resume_wzd_b">
                      <span class="user_resume_wzd_c" style="width: 75%"></span>
                    </div>
                    <span class="user_resume_wzd_r">75% </span>
                  </div>

                  <div class="myresume_type">
                    <span class="myresume_type_s">类型：标准简历</span>
                    <span class="myresume_type_s"
                      >更新时间：2025-06-12 09:30:19</span
                    >
                    <span class="myresume_type_s">被浏览：0</span>
                    <span class="myresume_type_s">
                      状态： <span class="myresume_state_ysh">已审核</span>
                    </span>
                  </div>
                </div>
                <div class="myresume_right">
                  <a href="javascript:void(0);" class="myresume_right_cz_fmr_a"
                    >设为默认</a
                  >
                  <span class="myresume_right_cz_fmr_line">|</span>
                  <a href="" class="myresume_right_cz_fmr_a">修改简历 </a>
                  <span class="myresume_right_cz_fmr_line">|</span>
                  <a href="" target="_blank" class="myresume_right_cz_fmr_a"
                    >预览简历</a
                  >
                  <span class="myresume_right_cz_fmr_line">|</span>
                  <a href="javascript:void(0)" class="myresume_right_cz_fmr_a"
                    >删除简历
                  </a>
                </div>
              </div> -->
            </div>
          </div>
        </div>
        <div class="clear"></div>
      </div>
    </div>
    <script>
      const highestDegree = {
        "1": "高中以下",
        "2": "高中",
        "3": "中专",
        "4": "大专",
        "5": "本科",
        "6": "硕士",
        "7": "博士"
      };
      const hunterStatus= {
        "0": "已离职，寻求新工作",
        "1": "在职，考虑更好工作",
        "2": "其他",
      }
      let resumeData = {
        defaultResume: null,
        backupResumes: [],
      };
      //渲染简历
      function renderResume(){
        $("#addDefaultResume").empty();
        $("#addBackUpResumes").empty();
        if (resumeData.defaultResume) {
              addDefaultResume(resumeData.defaultResume);
            } else {
                noResumeData();
            }
            if (resumeData.backupResumes.length > 0) {
              resumeData.backupResumes.forEach((item) => {
                addBackUpResumes(item);
              });
            }
      }
      function processResumeData(data) {
        resumeData = {
            defaultResume: null,
            backupResumes: [],
        }
        resumeData.defaultResume = data.find((item) => item.def === "1");
        resumeData.backupResumes = data
          .filter((item) => item.def !== "1")
          .sort((a, b) => b.viewNum - a.viewNum );
        console.log(resumeData);
      }
      $(function () {
        getResumeData();
      });
      //获取简历列表
      function getResumeData(){
        httpJsonRequest(
          "/resume/listByUserId",
          "POST",
          null,
          localStorage.getItem("token"),
          "application/json",
          function (res) {
            console.log(res);
            processResumeData(res.data);
            renderResume();
          }
        );
      }
      //刷新简历
      function refreshResume(id){
        httpJsonRequest(
            "/resume/refreshResume",
            "POST",
            id,
            localStorage.getItem("token"),
            "application/json",
            function(res){
                getResumeData();
            }
        )
      }
      //预览简历
      function viewResume(id){
        sessionStorage.setItem('resumeId',id)
        location.href = "./resumeview"
      }
      //简历设为默认
      function setDefaultResume(id){
        httpJsonRequest(
            "/resume/setDefaultResume",
            "POST",
            id,
            localStorage.getItem("token"),
            "application/json",
            function(res){
                getResumeData();
            }
        )
      }
      //删除简历
      function deleteResume(id){
        const ids=[]
        ids.push(id)
        httpJsonRequest(
                "/resume/deleteResume",
                "POST",
                ids,
                localStorage.getItem("token"),
                "application/json",
                function(res){
                    getResumeData();
                }
        )
      }
      //没有简历
      function noResumeData() {
        $("#addDefaultResume").append(function () {
          var html = "";
          html += `<div class="index_no_resume_box" id="yindao" style="display:block;">`;
          html += `<div class="yun_prompt_writingicon" style="padding-top:0px"><i class="yun_prompt_writingicon_cj"></i></div>`;
          html += `<div class="yun_prompt_writing">亲，您还没有简历</div>`;
          html += `<div class="yun_prompt_writing_obtain">简历是求职第一步，优质的简历助您找到满意工作！</div>`;
          html += `<div class="yun_prompt_writing_tip">创建简历请认真填写</div>`;
          html += `<div class="yun_prompt_writing_operation">`;
          html += `<a href="resume1" class="yun_prompt_writing_operation_bth">立即创建简历</a>`;
          html += `<a class="close_yd" href="javascript:void(0)">暂不创建</a>`;
          html += ` </div>`;
          html += `</div>`;
          return html;
        });
      }

      //挂在默认简历
      function addDefaultResume(defaultResumeData) {
        $("#addDefaultResume").append(function () {
          var html = "";
          html += `<div class="user_resume_photo">`;
          html += `<a href="">`;
          html += `<img src="" border="0" />`;
          html += `</a>`;
          html += `</div>`;
          html += `<div class="user_resume_info">`;
          html += `<div class="user_resume_name">`;
          html += `${defaultResumeData.name}<span class="user_resume_job">${defaultResumeData.intent}</span><span class="user_resume_mr">默认</span>`;
          html += `</div>`;
          html += `<div class="user_resume_p">`;
          html += `${
            defaultResumeData.birthdate
              ? new Date().getFullYear() -
                new Date(defaultResumeData.birthdate).getFullYear()
              : "未知"
          }岁<span class="user_resume_line">|</span> ${
            defaultResumeData.workDuration
          }年经验<span class="user_resume_line">|</span>`;
          html += highestDegree[defaultResumeData.highestDegree];
          html += `</div>`;
          html += `<div class="user_resume_p2">${hunterStatus[defaultResumeData.hunterStatus]}</div>`;
          html += `</div>`;
          html += `<div class="user_resume_c">`;
          html += `<div class="user_resume_wzd" id="tipid" rid="2">`;
          html += `<span class="user_resume_wzd_name">简历完整度：</span>`;
          html += `<div class="user_resume_wzd_b">`;
          html += `<span class="user_resume_wzd_c" style="width: 75%"></span>`;
          html += `</div>`;
          html += `<span class="user_resume_wzd_r">75% </span>`;
          html += `</div>`;
          html += `<div class="clear"></div>`;
          html += `<div class="user_resume_p user_resume_pd">`;
          html += `更新日期：${defaultResumeData.refreshTime}`;
          html += `</div>`;
          html += `<div class="user_resume_p">被浏览：${defaultResumeData.viewNum}</div>`;
          html += `</div>`;
          html += `<div class="user_resume_cz">`;
          html += `<div class="user_resume_cz_p">`;
          html += `<a href="javascript:void(0)" class="user_resume_cz_a user_resume_cz_icon5" onclick="deleteResume(${defaultResumeData.id})">`;
          html += `删除简历</a>`;
          html += `</div>`;
          html += `<div class="user_resume_cz_p">`;
          html += `<a href="" class="user_resume_cz_a user_resume_cz_icon3">修改简历</a>`;
          html += `</div>`;
          html += `<div class="user_resume_cz_p">`;
          html += `<a target="_blank" class="user_resume_cz_a user_resume_cz_icon4" onclick="viewResume(${defaultResumeData.id})">预览简历</a>`;
          html += `</div>`;
          html += `<div class="user_resume_cz_p">`;
          html += `<a href="javascript:void(0)" class="user_resume_cz_a user_resume_cz_icon2" onclick="refreshResume(${defaultResumeData.id})">刷新简历</a>`;
          html += `</div>`;
          html += `</div>`;
          return html;
        });
      }
      //挂载备用简历
      function addBackUpResumes(backUpResume) {
        $("#addBackUpResumes").append(function () {
          var html = "";
          html += `<div class="myresume mt20" style="margin-left: 0px">`;
          html += `<span class="myresume_by">备用</span>`;
          html += `           <div class="myresume_left ">`;
          html += `<div class="myresume_name">`;
          html += `<a href="">${backUpResume.intent}</a>`;
          html += ` </div>`;
          html += ` <div class="user_resume_wzd " id="tipid" rid="1044751">`;
          html += `  <span class="user_resume_wzd_name">简历完整度：</span>`;
          html += ` <div class="user_resume_wzd_b"><span class="user_resume_wzd_c" style="width:75%"></span>`;
          html += `   </div>`;
          html += ` <span class="user_resume_wzd_r">75% </span>`;
          html += ` </div>`;
          html += ` <div class="myresume_type">`;
          html += `  <span class="myresume_type_s">类型：标准简历</span>`;
          html += `   <span class="myresume_type_s">更新时间：${backUpResume.refreshTime}</span>`;
          html += `   <span class="myresume_type_s">被浏览：${backUpResume.viewNum}</span>`;
          html += `    <span class="myresume_type_s">`;
          html += `         状态：<span class="myresume_state_ysh">${backUpResume.status}</span> </span>`;
          html += `  </div>`;
          html += ` </div>`;
          html += ` <div class="myresume_right ">`;
          html += `  <a href="javascript:void(0);" class="myresume_right_cz_fmr_a" onclick="setDefaultResume(${backUpResume.id})">设为默认</a>`;
          html += `  <span class="myresume_right_cz_fmr_line">|</span>`;
          html += `   <a href="" class="myresume_right_cz_fmr_a">修改简历 </a>`;
          html += `  <span class="myresume_right_cz_fmr_line">|</span>`;
          html += `   <a target="_blank" class="myresume_right_cz_fmr_a" onclick="viewResume(${backUpResume.id})">预览简历</a>`;
          html += `   <span class="myresume_right_cz_fmr_line">|</span>`;
          html += `  <a href="javascript:void(0)" class="myresume_right_cz_fmr_a" onclick="deleteResume(${backUpResume.id})">删除简历 </a>`;
          html += `  </div>`;
          html += `</div>`;
          return html;
        });
      }
    </script>
    <div class="clear"></div>
    <div class="foot"></div>
  </body>
</html>
